<?php

namespace app\models;

use yii;
use yii\db\Query;

class LandEmail extends BaseModel
{

    public function __construct()
    {
        $this->table = yii::$app->db->tablePrefix . 'landing_email';
    }

    public function all($where = [], $offset = false, $limit = false, $order = false)
    {
        $db = new Query();
        $db->select('*')->from($this->table);
        if ($offset) {
            $db->offset($offset);
        }
        if ($limit) {
            $db->limit($limit);
        }
        if ($order) {
            $db->orderBy($order);
        }
        return $db->all();
    }

    public function one($where = [])
    {

    }

    public function size($where = []): int
    {
        $db = new Query();
        $db->select('count(id) as num')->from($this->table);
        $re = $db->one();
        return $re ? $re['num'] : 0;
    }
}
